import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/widget/image/base_image.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'dart:math' as math;

class PlusCommodityToggleMoreInfoBtn extends StatelessWidget {
  final VoidCallback onTap;
  final bool isOpen;

  String get _labelForToggle {
    return isOpen ? '收起更多设置' : '展开更多设置';
  }

  double get _angle {
    return isOpen ? math.pi : 0;
  }

  const PlusCommodityToggleMoreInfoBtn({
    Key key,
    @required this.isOpen,
    this.onTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        color: Colors.white,
        padding: EdgeInsets.only(
          top: 38.w,
          bottom: 38.w,
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              _labelForToggle,
              style: TextStyleConstant().normal_4_28,
            ),
            Container(
              margin: EdgeInsets.only(
                left: 5.w,
              ),
              child: Transform.rotate(
                angle: _angle,
                child: BaseImage(
                  'assets/image/double_arrow_down_icon.png',
                  width: 16.w,
                  height: 20.w,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
